<script type="text/javascript" src="/js/prototype.js"></script>
<style>
table td{ text-align:center}
</style>
	<div class="path" style="margin-top:45px; line-height:20px">Ps:天气更新规则<span style="color:red;"> [国家天气网刷新天气时间点为8:00、11:00、18:00三个时间点]</span> 以下天气都为最新时间点天气
若不是最新时间天气，请点击<span style="color:red;">“手动更新”</span>天气按钮
	</div>
 	
	<div class="clearfix txtleft search" style="background-color:#f8f8f8; padding:10px; margin:10px 0px;">        
		<input type="button" class="btn btn-success" value="刷新天气" onclick="opupdate()" >
		<input type="button" class="btn btn-success" value="清除过期数据" onClick="window.location.href='/<*$controller*>/delete'"> 
		
    	<div id="ajax" style="text-align:left; padding-left:20px; padding-top:10px; display:none"><img src="/images/ajax_loader.gif" /></div>
	</div>	
  <*if $result|@count neq 0*>
	<div class="table_content">
		<div class="ta_top"></div>
		<div class="ta_in">
        <table cellpadding="0" cellspacing="0" class="table">
			<tr>
			<th style="width:100px;">时间</th>
			<th style="width:100px;">城市</th>
			<th style="width:200px;">天气</th>
			<th style="width:120px;">温度</th>
			<th style="width:100px;">发布时间</th>
			<th style="width:100px;">空气质量</th>
			<th style="width:120px;">细颗粒物</th>
			<th>&nbsp;</th>
		</tr>
		<*foreach from=$result item=a key =key name=foo*>
		<tr>
			<td><*$a.day*></td>
			<td><*$a.cityname*></td>
			<td style="text-align:left; padding-left:10px;"><*if $a.img1*><img src="http://img.yunxiaoche.com/weather/<*$a.img1*>" alt=" <*$a.weather*>"/> <img src="http://img.yunxiaoche.com/weather/<*$a.img2*>" alt=" <*$a.weather*>"/><*/if*> <*$a.weather*> </td>
			<td><*$a.temp2*>~<*$a.temp1*></td>
			<td><*$a.ptime*></td>
			<td><*$a.quality*></td>
			<td><*$a.pm2_5*></td>
            <td>&nbsp;</td>
		</tr>
		<*/foreach*>
        <tr>
        	<td colspan="7"> <*$page*></td>
            <td>&nbsp;</td>
        </tr>
        </table>
		<*else*>
		今天天气还未生成，请点击<a href="/<*$controller*>/opupdate">手动更新</a>
		<*/if*>
			  
		</div>
		<div class="ta_bottom"></div>
	</div>
	<!--表格展示-->

<script type="text/javascript">
function opupdate()
{
	var url = '/<*$controller*>/opupdate';
	var pars = '';
	document.getElementById('ajax').style.display='block';
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_course});
}

function showResponse_course(originalRequest)
{
	document.getElementById('ajax').style.display='none';
	alert('手动刷新天气成功！');
	window.location.reload(); 	
}
</script>
